<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>带模板的组件</title>
</head>
<body>
    <script type="module">
        import { createApp } from '../../public/petite-vue-module.js'
      
        function Counter(props) {
          return {
            $template: '#counter-template',
            count: props.initialCount,
            inc() {
              this.count++
            }
          }
        }
      
        createApp({
          Counter
        }).mount()
      </script>
      <!-- 独立脚本还好！！！ -->
      <template id="counter-template">
        My count is {{ count }}
        <button @click="inc">++</button>
      </template>
      
      <!-- reuse it -->
      <div v-scope="Counter({ initialCount: 1 })"></div>
      <div v-scope="Counter({ initialCount: 2 })"></div>
</body>
</html>